package lormi.meipin.controller.api;

import lormi.meipin.common.Result;
import lormi.meipin.controller.BaseController;
import lormi.meipin.dto.CurrencyDto;
import lormi.meipin.exception.LMException;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;


/**
 * 商家关注人才
 * */
@RestController
@RequestMapping(value="v2/focustalent/",method=RequestMethod.POST,produces = "application/json; charset=utf-8")
public class FocusTalentController extends BaseController{

	/**
	 * 商家=》关注(收藏)一个简历
	 * @Param userid 用户ID
	 * @Param usertype 用户类型
	 * @Param focusid 被关注者ID
	 * */
	@RequestMapping("focus")
	@Valid
	public String focusPosition(@NotNull(message="100033") @RequestParam(value="userid",required=false) Integer userid,
			@NotNull(message="100033") @RequestParam(value="focusid",required=false) Integer focusid) throws Exception{
		
		focusTalentService.focusTalent(userid, focusid);
		return Result.success();
	}
	
	/**
	 * 商家=》取消对一个人才的关注
	 * @Param userid 用户ID
	 * @Param usertype 用户类型
	 * @Param focusid 关注者ID
	 * */
	@RequestMapping("cancel")
	@Valid
	public String delFocusPosition(@NotNull(message="100033") @RequestParam(value="userid",required=false) Integer userid,
			@NotNull(message="100033") @RequestParam(value="focusid",required=false) Integer focusid) throws LMException{
		
		focusTalentService.cancelFocusTalent(userid, focusid);
		return Result.success();
	}
	
	
	/**
	 * 商家=》获取关注的人才信息
	 * @Param userid 用户ID
	 * @Param usertype 用户类型
	 * @Param pagesize 每页的条数
	 * @Param pagenow 当前页数
	 * */
	@RequestMapping("list")
	public String getFocusTalent(@Valid CurrencyDto currencyDto,BindingResult result) throws LMException{
		checkResult(result);
		
		return Result.success(focusTalentService.getFocusList(currencyDto));
	}
	
}
